/**
 * Copyright (c) 2017, Alex. All rights reserved.
 */
package com.oschina.bottle.sample.web.web;

import com.oschina.bottle.sample.web.web.interceptor.GlobalInterceptor;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.boot.autoconfigure.web.WebMvcProperties;
import org.springframework.boot.autoconfigure.web.WebMvcRegistrations;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;

/**
 * mvc配置
 *
 * @author <a href="mailto:zhongchao@gegejia.com">zhong</a>
 * @version 1.0 2017/10/11
 * @since 1.0
 */
@Configuration
public class WebAutoConfiguration extends WebMvcAutoConfiguration.EnableWebMvcConfiguration
{
    @Autowired
    private GlobalInterceptor globalInterceptor;

    public WebAutoConfiguration(ObjectProvider<WebMvcProperties> mvcPropertiesProvider, ObjectProvider<WebMvcRegistrations> mvcRegistrationsProvider,
        ListableBeanFactory beanFactory)
    {
        super(mvcPropertiesProvider, mvcRegistrationsProvider, beanFactory);
    }

    @Override
    protected void addInterceptors(InterceptorRegistry registry)
    {
        super.addInterceptors(registry);
        registry.addInterceptor(globalInterceptor).addPathPatterns("/**");
    }
}
